/**
 * The AndCreationTool allows the user to create a new And
 * by clicking at the place where there should be the top/left corner.
 * The And currently have a fixed size of 20 by 40 pixels.
 * 
 * @author Giuseppe Mendola (giuseppe.mendola@usi.ch);Gregory Banfi (gregory.banfi@usi.ch);
 */

package ch.usi.inf.pf2.gui;

import java.awt.event.MouseEvent;

import ch.usi.inf.pf2.Gates.And;

public final class AndCreationTool extends Tool {

	public AndCreationTool(final Model model) {
		super(model, "Create And Gate", "andGate.gif");
	}

	/**
	 * This method responds to the mouseClicked event on the andCreationTool.
	 * When the user clicks it prints a message, and creates a new and object
	 * with a predefined value Unknown at the position of the mouse clicked.
	 * Then the and is added to the drawing, the previous selection is cleared
	 * and the new and is selected.
	 */
	@Override
	public void mouseClicked(final MouseEvent ev) {
		//System.out.println("mouseClicked: " + ev);
		 And and = new And(getInputPins(), getOutputPin(), ev.getX(),
				ev.getY());
		getDrawing().add(and);
		getSelection().clear();
		getSelection().add(and);
		getGates().add(and);
		Drawing.getInputs().clear();
	}

}